//判断文件类型的模块
const path = require('path')

//引入静态资源模块
const servestatic = require('serve-static')
//设置静态资源路径
const serve = servestatic(path.join(__dirname, 'public', 'css'))

// 引入网络服务器模块
const http = require('http')

// 导入连接数据库模块
require('./model/connect.js')

//引入路由模块
const router = require('./model/router')

// 创建服务器对象
const app = http.createServer()



// 监听服务器请求使劲按
app.on('request', (req, res) => {

    req.url = req.url == '/' ? '/add' : req.url
    //4.启用路由
    router(req, res, () => {
    })

    //静态资源访问功能
    serve(req, res, () => { })

})

// 监听80端口
app.listen(80, () => {
    console.log('服务器启动成功..., http://127.0.0.1')
})